package com.ai.bitcoin;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
import lombok.Setter;
import org.slf4j.helpers.BasicMarkerFactory;

import java.util.Objects;

/**
 * 日志标记过滤器
 */
public class LogbackMarkerFilter extends Filter<ILoggingEvent> {
    /**
     * 日志标记
     */
    @Setter
    private String marker;

    @Override
    public FilterReply decide(ILoggingEvent event) {
        if (Objects.equals(new BasicMarkerFactory().getMarker(marker), event.getMarker())) {
            return FilterReply.NEUTRAL;
        }
        else {
            return FilterReply.DENY;
        }
    }
}
